#ifndef RIGID_BODY_BULLET
#define RIGID_BODY_BULLET

//#include <QObject>
#include <EObject.h>
#include <BulletClassDataSource/CollisionObjectBullet.h>
#include <QVarintTrigger.h>
#include <QVector3D>
#include <osg/MatrixTransform>
#include <QMatrix4x4>

#include <Point3D.h>

class RigidBodyBullet : public CollisionObjectBullet
{
    Q_OBJECT
    Q_ENUMS(COLLISION_SHAPE)
    Q_PROPERTY(QVarintTrigger Rebuild READ getTriggerRebuild WRITE setTriggerRebuild)
    Q_PROPERTY(QString TransformNodeName READ getTransformNodeName WRITE setTransformNodeName)
    Q_PROPERTY(COLLISION_SHAPE CollisionShapeType READ getCollisionShapeType WRITE setCollisionShapeType)
    Q_PROPERTY(double Mass READ getMass WRITE setMass)
    Q_PROPERTY(QVector3D GridIndex READ getGridIndex WRITE setGridIndex)
    Q_PROPERTY(double GridSphere READ getGridSphereRaidus WRITE setGridSphereRaidus )
    //Q_PROPERTY(QMatrix4x4 SDFSampleMatrix READ  getSDFSampleMatrix WRITE setSDFSampleMatrix)
    Q_PROPERTY(QVector3D SDFSamplePos READ getSDFSamplePosition WRITE setSDFSamplePosition)
    Q_PROPERTY(QVarintTrigger DOFCompute READ getTriggerDOFCompute WRITE setTriggerDOFCompute)
    //Q_PROPERTY(QVector3D DofTest READ getDofTest WRITE setDofTest)
    Q_PROPERTY(QVarintTrigger SprayCompute READ getTriggerSprayCompute WRITE setTriggerSprayCompute)
    //Q_PROPERTY(int TrajCheck READ getTrajCheck WRITE setTrajCheck)

public:

    enum COLLISION_SHAPE
    {
        BOX_SHAPE_PROXYTYPE,
        TRIANGLE_SHAPE_PROXYTYPE,
        _______TETRAHEDRAL_SHAPE_PROXYTYPE,
        CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE,
        _______CONVEX_HULL_SHAPE_PROXYTYPE,
        _______CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE,
        _______CUSTOM_POLYHEDRAL_SHAPE_TYPE,
    //implicit convex shapes
        _______IMPLICIT_CONVEX_SHAPES_START_HERE,
        SPHERE_SHAPE_PROXYTYPE,
        _______MULTI_SPHERE_SHAPE_PROXYTYPE,
        _______CAPSULE_SHAPE_PROXYTYPE,
        _______CONE_SHAPE_PROXYTYPE,
        _______CONVEX_SHAPE_PROXYTYPE,
        _______CYLINDER_SHAPE_PROXYTYPE,
        _______UNIFORM_SCALING_SHAPE_PROXYTYPE,
        _______MINKOWSKI_SUM_SHAPE_PROXYTYPE,
        _______MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE,
        _______BOX_2D_SHAPE_PROXYTYPE,
        _______CONVEX_2D_SHAPE_PROXYTYPE,
        _______CUSTOM_CONVEX_SHAPE_TYPE,
        //concave shapes
        _______CONCAVE_SHAPES_START_HERE,
        //keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy!
        TRIANGLE_MESH_SHAPE_PROXYTYPE
    };



    RigidBodyBullet(QObject *parent = 0);
    virtual ~RigidBodyBullet();

    void setTransformNodeName(const QString& name);
    QString getTransformNodeName();

    COLLISION_SHAPE getCollisionShapeType();
    void setCollisionShapeType(COLLISION_SHAPE shapeType);

    double getMass();
    void setMass(double mass);

    QVarintTrigger getTriggerRebuild();
    void setTriggerRebuild(QVarintTrigger trigger);

    QVector3D getGridIndex();
    void setGridIndex(QVector3D gridIndex);

    double getGridSphereRaidus();
    void setGridSphereRaidus(double doubleValue);

    QMatrix4x4 getSDFSampleMatrix();
    void setSDFSampleMatrix(QMatrix4x4 matrix);

    QVector3D getSDFSamplePosition();
    void setSDFSamplePosition(QVector3D position);

    QVarintTrigger getTriggerDOFCompute();
    void setTriggerDOFCompute(QVarintTrigger trigger);

    QVector3D getDofTest();
    void setDofTest(QVector3D position);

    QVarintTrigger getTriggerSprayCompute();
    void setTriggerSprayCompute(QVarintTrigger trigger);


//    int getTrajCheck();
//    void setTrajCheck();
//    bool getIsShowGridExamplePoint();
//    void setIsShowGridExamplePoint(bool boolValue);

//---------------------------------------
    btRigidBody* getRigidBody();

    void rebuildRigidBody();

    virtual void refreshItemTest();

    void rebuildSDFSphereNode();
protected:
    QString m_transformNodeName;
    COLLISION_SHAPE m_collisionShapeType;
    double m_mass;
    QVector3D m_gridIndex;
    QVector3D m_dofTest;
    osg::ref_ptr<Point3D> m_sdfPoint3DNode;
    QMatrix4x4 m_sdfPointMatrix;
    //int m_trajCheck;
};
#endif // RIGID_BODY_BULLET
